package com.aaa.jx.controller;

import com.aaa.jx.entity.TabUser;
import com.aaa.jx.service.TabUserService;
import com.aaa.jx.service.impl.TabUserServiceImpl;

import com.util.LayData;
import com.util.PrintJsonData;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

/**
 * (TabUser)表控制层
 *
 * @author makejava
 * @since 2023-04-26 17:03:31
 */


@WebServlet(name = "TabUserServlet", value = "/TabUserServlet")
public class TabUserServlet extends HttpServlet {

    private TabUserService tabUserService = new TabUserServiceImpl();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 
        String method = req.getParameter("method");
        if (method==null){
          

        }else if(method.equals("query")){
            query(req,resp);
            return;
        }else if(method.equals("add")){
            add(req,resp);
            return;
        }else if(method.equals("upd")){
            upd(req,resp);
            return;
        }else if(method.equals("del")){
            del(req,resp);
            return;
        }

    }

  

    private void del(HttpServletRequest req, HttpServletResponse resp) {
    }

    private void upd(HttpServletRequest req, HttpServletResponse resp) {
    }

    private void add(HttpServletRequest req, HttpServletResponse resp) {
    }

    private void query(HttpServletRequest req, HttpServletResponse resp) {
        List<TabUser> tabUsers = tabUserService.queryAll(null);
        System.out.println("---------------------"+tabUsers);
        long count = tabUserService.count(null);
        LayData success=new LayData(0,"",count,tabUsers);
        PrintJsonData.printData(resp,success);

    }
}




